package com.main.thread;

/**
 * @author Zhang Guangyong
 * @desacription 线程示例
 * @date 2019年07月10日 9:59
 */
public class ThreadTest extends Thread {

    private int count = 10;

    public void run() {
        System.out.println("第[" + this.getId() + "]继承线程开始");
        System.out.println("count: "+this.count);
        System.out.println("getName: "+this.getName());
        System.out.println("getState: "+this.getState());
        System.out.println("getThreadGroup: "+this.getThreadGroup());


        while (true) {
            System.out.println("count: " + count);

            try {

                if (count == 5) {
                    System.out.println("第[" + this.getId() + "]线程休眠开始");
                    Thread.sleep(5000);
                }
            } catch (InterruptedException e) {
                e.printStackTrace();
            }

            if (--count == 0) {
                return;
            }
        }
    }

}
